package com.vf.admin.client.service.impl;

import com.vf.admin.client.dao.AppDynamicDao;
import com.vf.admin.client.dao.AppFeedbackDao;
import com.vf.admin.client.dao.AppRoomDao;
import com.vf.admin.client.dao.AppUserDao;
import com.vf.admin.client.service.AppFeedbackRecordService;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppFeedback;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

@Service
public class AppFeedbackServiceImpl implements AppFeedbackRecordService {
    @Autowired
    private AppFeedbackDao appFeedbackDao;

    @Autowired
    AppUserDao appUserDao;

    @Autowired
    AppRoomDao appRoomDao;

    @Autowired
    AppDynamicDao appDynamicDao;


    @Override
    public List<AppFeedback> findList(Map<String, Object> paraMap, SplitPageBean splitPage) {
        return appFeedbackDao.findList(paraMap, splitPage);
    }

    @Override
    public List<AppFeedback> findList(Map<String, Object> paraMap) {
        return appFeedbackDao.findList(paraMap);
    }

    @Override
    public AppFeedback get(Integer id) {
        return appFeedbackDao.get(id);
    }

    @Override
    public void save(AppFeedback haoYou) {
        appFeedbackDao.save(haoYou);
    }

    @Override
    public void del(Integer id) {
        appFeedbackDao.del(id);
    }

    @Override
    public void chuli(Integer id,String remark) {
        appFeedbackDao.chuli(id,remark);
    }

//    @Transactional
//    @Override
//    public Result addFeedback(Integer userid, Integer bjbuserid, Integer leixing, String feedbacktype, String img, String message) {
//        AppFeedback appFeedback = new AppFeedback();
//        AppUser appUser = appUserDao.get(userid);
//        if (appUser == null) {
//            return this.errorJSON("用户不存在");
//        }
//        if (leixing == 1) {//举报动态
//            appFeedback.setLeixing(1);
//            AppDynamic appDynamic = appDynamicDao.get(bjbuserid);
//            if (appDynamic == null) {
//                return this.errorJSON("动态不存在");
//            }
//            bjbuserid = appDynamic.getUserid();//获取下单人
//            appFeedback.setNrbiaoti(appDynamic.getMessage());
//        }
//        if (leixing == 2) {//举报房间
//            appFeedback.setLeixing(2);
//            AppRoom appRoom = appRoomDao.get(bjbuserid);
//            if (appRoom == null) {
//                return this.errorJSON("房间不存在");
//            }
//            bjbuserid = appRoom.getUserid();//获取下单人
//            appFeedback.setNrbiaoti(appRoom.getRoomname());
//        }
//        if (leixing == 3) {//举报好友
//            appFeedback.setLeixing(3);
//            appFeedback.setNrbiaoti("举报用户");
//        }
//        AppUser bjappUser = appUserDao.get(bjbuserid);
//        if (bjappUser == null) {
//            return this.errorJSON("被举报用户不存在");
//        }
//        appFeedback.setUserid(userid);
//        appFeedback.setPic(appUser.getPic());
//        appFeedback.setNick(appUser.getNick());
//        appFeedback.setPhone(appUser.getLoginname());
//        appFeedback.setBjbuserid(bjbuserid);
//        appFeedback.setBjbpic(bjappUser.getPic());
//        appFeedback.setBjbnick(bjappUser.getNick());
//        appFeedback.setBjbphone(bjappUser.getLoginname());
//        appFeedback.setFeedbacktype(feedbacktype);
//        appFeedback.setImg(img);
//        appFeedback.setMessage(message);
//        appFeedback.setCreatetime(new Date());
//        appFeedback.setState(1);//状态  1、未处理  2、已处理 默认 1未处理
//        appFeedbackDao.save(appFeedback);
//        return sucess();
//    }
}
